<template>
  <input type="text"  v-model="a1">
  <input type="text"  v-model="a2">
  <br>
  <button @click="calculator('+')" >加</button>
  <button @click="calculator('-')" >减</button>
  <button @click="calculator('*')" >乘</button>
  <button @click="calculator('/')" >除</button>
  <br>
  <textarea v-model="res"></textarea>
</template>

<script setup>
  import {ref} from "vue";
  const a1=ref("");
  const a2=ref("");
  const res=ref('');
  const calculator=(single)=>{
     res.value=eval(a1.value+single+a2.value);
 }
</script>

<style scoped>

</style>